Method for preparing compressed image data file, image data compression device, and photographic device

ABSTRACT

A method for carrying out a step of extracting a portion of a predetermined size from the image data, and a step of preparing a predetermined number of compressed partial data compressed with different compression parameter values by repeating preparation of compressed partial data by compressing the partial data in predetermined format for the predetermined number of times with the compression parameter value used in the predetermined format changed for each compression, on the entire image data. The method also calculates the total of the data sizes of all of the compressed partial data compressed with the same compression parameter value for each of the compression parameter values and prepares the compressed image data file from compressed partial data compressed with a compression parameter value for which the total is not larger than a given threshold and which is the closest value to the threshold.

RELATED APPLICATION INFORMATION

This application is a continuation of international patent applicationNo. PCT/JP2004/005108 filed Apr. 9, 2004.

BACKGROUND OF THE INVENTION

(i) Field of the Invention

This invention relates to a method for preparing a compressed image datafile, an image data compression device and a photographic device.

(ii) Description of the Related Art

In recent years, cameras have been increasingly incorporated intoelectronic devices including personal computers, PDAs and cellularphones. Like conventional digital cameras which are used specificallyfor photography, these devices are also capable of photographing stillimages and moving images. To inform a user of how many more pictures canbe taken, a digital camera which is a device used specifically forphotography generally has a function of estimating the number ofpictures that can be still taken. In the era of film cameras, it waspossible to clearly know the number of pictures that can be still takensince one film is physically consumed by each photographing. However, inthe case of digital cameras which store pictures as digital data, userscannot clearly know the number of pictures that can be still takenwithout any devices since the data size of image data file produced byeach photographing is generally not a constant value. If the number ofpictures that can be still taken cannot be known, it is difficult forusers to form a photographing plan, which is inconvenient for the users.Accordingly, conventional digital cameras used specifically forphotography have a function of estimating the number of pictures thatcan be still taken by suppressing a variation in the data size of imagedata file produced by each photographing and keeping the data size asconstant as possible.

The reason why the data size of image data file varies for eachphotographing in a digital camera is that the image data is compressed.To store as many image data in a data recording medium as possible, theimage data are generally stored in the data recording medium in acompressed form. One or more compression parameters are associated withthis compression, and in compression in JPEG format which is used incurrent digital cameras, compression parameters called Q factors and Qtables are associated with the compression. The data sizes of image dataafter compression vary depending on the contents of photographed imageseven if the image data are compressed with the same parameter. For thisreason, when the same compression parameter value is used for all imagedata, the size of data file of produced compressed image varies for eachphotographing, and it turns out to be difficult to estimate the numberof pictures that can be still taken. Consequently, as described inJapanese Patent Application Laid-Open No. 233373/1992, conventionaldevices used specifically for photography compress image data preparedby photographing with different compression parameter values, and whenthe image data could be compressed to a desired data size, the devicesuse the compressed image data for an image data file which is stored atthe end, i.e. a compressed image data file to keep the data size ofcompressed image data file to be produced constant. Therefore, the valueof compression parameter used for compression of image data differs foreach photographing.

A method for preparing compressed image data in a conventional deviceused specifically for photography will be described by use of FIG. 13.FIG. 13 is a block diagram illustrating a conventional device usedspecifically for photography. A digital camera 202 which is a deviceused specifically for photography comprises a lens 204, a solid-stateimage sensor 206, an A/D converter 208, an image processing DSP 210, aCPU 212, a main storage unit 214, an external storage unit 216, adisplay 218 and a user interface 220 such as a shutter button. Thedigital camera 202 exchanges signals with these units via a bus 222. Atthe press of the shutter button of the user interface 220, the CPU 212issues a command to initiate photographing, light having passed throughthe lens 204 is converted into an electrical signal by the solid-stateimage sensor 206, and the electrical signal is digitized by the A/Dconverter 208 and then stored in the main storage unit 214 temporarily.All signals output from all picture elements of the solid-state imagesensor 206 are stored in the main storage unit 214 as digital data.Then, the DSP 210 reads out the digitized output signals of thesolid-state image sensor 206 which are stored in the main storage unit214 and prepares image data corresponding to one photographed frame fromthe data. The image data is in RGB format or YUV format. The DSP 210stores the prepared image data corresponding to one frame in the mainstorage unit 214 temporarily.

Then, the DSP 210 reads out the prepared image data corresponding to oneframe from the main storage unit 214, compresses the image data in JPEGformat with a compression parameter set at a predetermined value toprepare a compressed image data file, and measures the data size of thecompressed image data file. If the data size is not a desired data size,the DSP 210 discards the compressed image data file, reads out theprepared image data from the main storage unit 214 again, compresses theimage data in JPEG format with a different compression parameter valueand measures the data size after compression. The DSP 210 repeats theabove operations to prepare compressed image data which is a finaloutput from image data compressed with a compression parameter valuewith which the desired data size is achieved and stores the compressedimage data in the main storage unit 216.

In summary, to keep the data sizes of compressed image data filesobtained by compressing image data as constant as possible, the methodfor preparing a compressed image data file which is implemented inconventional digital cameras comprises compressing entire image data tobe compressed with a compression parameter value, checking the size ofthe compressed data, and compressing the entire image data to becompressed again with another compression parameter value when the sizeof the compressed data is larger than a desired size.

SUMMARY OF THE INVENTION

As described above, to estimate the number of photographs that can bestill taken, it is necessary to suppress a variation in the data sizesof image data files to be stored which are produced by photographing andkeep a capacity in a recording medium which is consumed by eachphotographing as constant as possible. That is, it is necessary to keepthe data sizes of compressed image data files obtained by compressingimage data as constant as possible. To fulfill the requirement, a methodfor preparing a compressed image data file according to the presentinvention is characterized as follows and different from the prior artin the following respect. More specifically, to prepare a compressedimage data file by compressing image data to be compressed, the methodof the present invention carries out:

-   a step of extracting a portion of a predetermined size from the    image data to be compressed, and-   a step of preparing a predetermined number of compressed partial    data compressed with different compression parameter values from the    partial data by repeating preparation of compressed partial data by    compressing the partial data in predetermined format for the    predetermined number of times with the compression parameter value    used in the predetermined format changed for each compression, on    the entire image data to be compressed, and-   the method of the present invention also calculates the total of the    data sizes of all of the compressed partial data compressed with the    same compression parameter value for each of the compression    parameter values and prepares the compressed image data file which    is to be a final output from compressed partial data compressed with    a compression parameter value for which the total is not larger than    a given threshold and which is the closest value to the threshold.    The predetermined format used for compression may be a JPEG format.    When compression in the JEPG format is used, Q factors or Q tables    defined in the JPEG format can be used as the compression parameters    which are changed during the repeating process.

The present invention includes the following image data compressiondevice. That is, the image data compression device is an image datacompression device which compresses image data to prepare a compressedimage data file, the device comprising:

-   partial data acquiring means,-   interleave compression means, and-   data file preparing means,    wherein-   the partial data acquiring means acquires a portion of a    predetermined size from the image data to be compressed,-   the interleave compression means prepares a number of compressed    partial data compressed with different compression parameter values    from the partial data by repeating preparation of compressed partial    data by compressing the partial data in predetermined format for a    predetermined number of times with the compression parameter value    used in the predetermined format changed for each compression and    outputs the compressed partial data sequentially, and-   the data file preparing means calculates the total of the data sizes    of all of the compressed partial data compressed with the same    compression parameter value for each of the compression parameter    values and prepares the compressed image data file from compressed    partial data compressed with a compression parameter value for which    the total is not larger than a given threshold and which is the    closest value to the threshold. When the total is larger than the    threshold for all of the compression parameter values, the    compressed image data file may be prepared from compressed partial    data compressed with a compression parameter value for which the    total is the smallest. The predetermined format used for compression    may be a JPEG format. When compression in the JEPG format is used, Q    factors or Q tables defined in the JPEG format can be used as the    compression parameters which are changed during the repeating    process.

The present invention also includes the following image data compressiondevice. That is, the image data compression device is an image datacompression device which compresses image data to prepare a compressedimage data file, the device comprising:

-   an image data compression section, and-   a data file preparing section,    wherein-   (A) the image data compression section comprises:-   a partial data acquiring section,-   an interleave compression section, and-   a data output section,-   (A1) the partial data acquiring section takes in a portion of a    predetermined size from the image data to be compressed and stores    the partial data temporarily,-   (A2) the interleave compression section compresses the partial data    stored in the partial data acquiring section in predetermined format    to prepare compressed partial data,-   (A3) the data output section outputs the compressed partial data,-   (A4) the interleave compression section comprises a number of    compression parameter values used in the predetermined format and    prepares a number of compressed partial data compressed with    different compression parameter values from the partial data,-   (A5) the data output section outputs the compressed partial data    sequentially,-   (B) the data file preparing section comprises:-   a data input section,-   a data storing section,-   a data size calculating section,-   a data size determining section, and-   a data shaping section,-   (B1) the data input section inputs the compressed partial data    output from the data output section,-   (B2) the data storing section stores the compressed partial data    input from the data input section,-   (B3) the data size calculating section calculates the total of the    data sizes of all of compressed partial data prepared from the same    image data and compressed with the same compression parameter value    out of the compressed partial data input from the data input section    for each of the different compression parameter values,-   (B4) the data size determining section determines that a compression    parameter value for which the total is not larger than a given    threshold and which is the closest value to the threshold is an    optimum compression parameter value, and-   (B5) the data shaping section prepares the compressed image data    file from compressed partial data compressed with the optimum    compression parameter value.

The data size determining section may be so constituted as to determinethat a compression parameter value for which the total is the smallestis an optimum compression parameter value when the total is larger thanthe threshold for all of the compression parameter values. Further, theinterleave compression section may be so constituted as to give markersindicating the compression parameter values used for compression to thecompressed partial data. The predetermined format used for compressionmay be a JPEG format. When compression in the JEPG format is used, Qfactors or Q tables defined in the JPEG format can be used as thecompression parameters. Further, when compression in the JEPG format isused, an RST marker defined in the JPEG format may be used as themarker.

The present invention also includes the following photographic device.That is, the photographic device is a photographic device comprising:

-   a camera module, and-   a host module,    wherein-   (A) the camera module comprises:-   a sensor section,-   an image data preparing section,-   a camera-module-side data storing section,-   a partial data acquiring section,-   an interleave compression section, and-   a data transmitting section,-   (A1) the sensor section converts incoming light into an electrical    signal,-   (A2) the image data preparing section prepares image data from the    electrical signal,-   (A3) the camera-module-side data storing section stores a part or    all of the image data temporarily,-   (A4) the partial data acquiring section takes in a portion of a    predetermined size from the image data stored in the    camera-module-side data storing section and stores the partial data    temporarily,-   (A5) the interleave compression section compresses the partial data    stored in the partial data acquiring section in predetermined format    to prepare compressed partial data,-   (A6) the data transmitting section transmits the compressed partial    data to the host module,-   (A7) the interleave compression section comprises a number of    compression parameter values used in the predetermined format and    prepares a number of compressed partial data compressed with    different compression parameter values from the partial data,-   (A8) the data transmitting section transmits the compressed partial    data sequentially,-   (B) the host module comprises:-   a data receiving section,-   a host-side data storing section,-   a data size calculating section,-   a data size determining section,-   a data shaping section, and-   a storage unit,-   (B1) the data receiving section receives the data transmitted from    the camera module,-   (B2) the host-side data storing section stores the compressed    partial data received by the data receiving section,-   (B3) the data size calculating section calculates the total of the    data sizes of all of compressed partial data prepared from the same    image data and compressed with the same compression parameter value    out of the compressed partial data received by the data receiving    section for each of the different compression parameter values,-   (B4) the data size determining section determines that a compression    parameter value for which the total is not larger than a given    threshold and which is the closest value to the threshold is an    optimum compression parameter value,-   (B5) the data shaping section prepares a compressed image data file    including information of the entirely compressed image data from    compressed partial data compressed with the optimum compression    parameter value, and-   (B6) the storage unit stores the compressed image data file. The    data size determining section may be so constituted as to determine    that a compression parameter value for which the total is the    smallest is an optimum compression parameter value when the total is    larger than the threshold for all of the compression parameter    values.

The host module may have a telephone function. For example, the hostmodule may have a telephone function using CDMA.

Further, the following embodiment can be applied when it is desired tohave the photographic device according to the present invention have afunction of previewing a photographed image. That is, the camera modulemay be so constituted that the image data preparing section preparespreview image data for preview from the electrical signal beforepreparing the image data and the data transmitting section transmits thepreview image data to the host module before transmitting the compressedpartial data, and the host module may be so constituted as to comprise adisplay device and receive the preview image data and displays it on thedisplay device.

In another embodiment when it is desired to have the photographic deviceaccording to the present invention have a preview function, the cameramodule may be so constituted that the data compression section preparespartial data for preview image whose resolution is lower than thepartial data from the partial data and the data transmitting sectiontransmits the partial data for preview image prepared from the partialdata and the compressed partial data sequentially, and the host modulemaybe so constituted as to comprise a display device and store thepartial data for preview image in the host-side data storing section,prepare image data for preview of the image data from the partial datafor preview image which is stored in the host-side data storing sectionby the data shaping section and display the image data for preview onthe display device.

In the photographic device according to the present invention, theinterleave compression section may be so constituted as to give markersindicating the compression parameter values used for compression to thecompressed partial data. The predetermined format used for compressionmay be a JPEG format. When compression in the JEPG format is used, Qfactors or Q tables defined in the JPEG format can be used as thecompression parameter values. Further, when compression in the JEPGformat is used, an RST marker defined in the JPEG format may be used asthe marker.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a block diagram illustrating an image data compression deviceaccording to the present invention.

FIG. 2 is a flowchart illustrating the operation of the image datacompression device according to the present invention.

FIG. 3 is a diagram illustrating interleave compression according to thepresent invention.

FIG. 4 is a diagram illustrating data output from an interleavecompression section of the image data compression device according tothe present invention.

FIG. 5 is a diagram illustrating measurement of the total data size ofcompressed partial data and selection of compressed partial data usedfor a final output.

FIG. 6 is a schematic diagram illustrating the hardware configuration ofan image data compression device according to an embodiment 1 of thepresent invention which prepares a compressed image data file in JPEGformat.

FIG. 7 is a flowchart illustrating the operation of an interleavecompression section in the embodiment 1.

FIG. 8 is a flowchart illustrating the operation of a data filepreparing section in the embodiment 1.

FIG. 9 is an external view of a camera-equipped cellular phone accordingto an embodiment 2 of the present invention.

FIG. 10 is a schematic diagram illustrating the hardware configurationof the camera-equipped cellular phone according to the embodiment 2.

FIG. 11 is a flowchart illustrating the operation of a camera module inthe embodiment 2.

FIG. 12 is a flowchart illustrating the operation of a host module inthe embodiment 2.

FIG. 13 is a block diagram illustrating a digital camera according tothe prior art.

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

Hereinafter, the best mode for carrying out the present invention willbe described with reference to the attached drawings.

A method for preparing a compressed image data file according to thepresent invention is a method for preparing a compressed image data fileby compressing image data, the method carries out:

-   (1) a step of extracting a portion of a predetermined size from the    image data, and-   (2) a step of preparing a predetermined number of compressed partial    data compressed with different compression parameter values from the    partial data by repeating preparation of compressed partial data by    compressing the partial data in predetermined format for the    predetermined number of times with the compression parameter value    used in the predetermined format changed for each compression, on    the entire image data, and-   the method also calculates the total of the data sizes of all of the    compressed partial data compressed with the same compression    parameter value for each of the compression parameter values and    prepares the compressed image data file from compressed partial data    compressed with a compression parameter value for which the total is    not larger than a given threshold and which is the closest value to    the threshold. The method for preparing a compressed image data file    can be implemented by the hardware configuration of an image data    compression device as shown in FIG. 1, for example.

FIG. 1 is a diagram illustrating functional blocks of image datacompression device according to the present invention. An image datacompression device 2 comprises a partial data acquiring section 4, aninterleave compression section 6, and a data file preparing section 10.

The partial data acquiring section 4 comprises a data acquisitioncontrol section 14 which controls extraction of partial data thatconstitutes a portion of original image data 12 to be compressed and abuffer memory 16 which stores extracted partial data temporarily. Thebuffer memory 16 does not have to store all of the image data, and it issufficient that the buffer memory 16 stores only a portion of the imagedata. Accordingly, the buffer memory 16 does not have to have a largecapacity.

The interleave compression section 6 comprises a data compressioncircuit 18 which compresses the partial data stored in the buffer memory16 in predetermined format to prepare compressed partial data and a datacompression control section 20 which controls the operation andcompression parameter values of the data compression circuit 18. Thedata compression circuit 18 has a number of compression parameter valuesused in the foregoing predetermined format. The compression format maybe a well-known JPEG format. When JPEG is used as the compressionformat, Q factors and a Q table that are defined in the JPEG format areavailable as compression parameters. When the values of thesecompression parameters are changed, the size and image quality ofcompressed data are changed. The data compression control section 20prepares a plurality of compressed partial data compressed by use ofdifferent compression parameter values from the partial data stored inthe buffer memory 16 by causing the data compression circuit 18 tooperate for a predetermined number of times with the value of thecompression parameter changed for each operation. Accordingly, aplurality of compressed partial data prepared from partial data by useof different compression parameter values are output from the interleavecompression section 6 sequentially.

The data file preparing section 10 comprises a memory controller 8, aRAM 9, a ROM 21 and a CPU 22. The RAM 9 stores the compressed partialdata output from the interleave compression section 6. The RAM 9 musthave a significantly larger capacity than the buffer memory 16 since itmust store all compressed partial data prepared from the image data 12to be compressed. The memory controller 8 allocates the addresses ofstorage locations in the RAM 9 to the compressed partial data outputfrom the interleave compression section 6 according to compressionparameter values used for compression so that partial data compressedwith the same compression parameter value are collectively stored in thesame area in the RAM 9. The ROM 21 stores a program which causes the CPU22 to operate as an information processing unit. The CPU 22 checks thedata stored in the RAM 9, calculates the total of the data sizes of allcompressed partial data compressed with the same compression parametervalue for each compression parameter value and prepares a compressedimage data file that is a final output of the image data compressiondevice 2 from compressed partial data compressed with a compressionparameter value for which the total is not larger than a given thresholdand which is the closest value to the threshold, in accordance with theprogram stored in the ROM 21. The compressed image data file resultsfrom compression of the entire original image data 12. For example, whena JPEG format is used as the predetermined format, the compressed imagedata file is prepared in standard JPEG file format. The preparedcompressed image data file is stored in the external storage unit 24 oroutput to an external device as it is.

Next, the operation of the image data compression device 2 according tothe present invention will be described by use of a flowchart of FIG. 2.First, processing is initiated in STEP S1. In STEP S2, the dataacquisition control section 14 extracts a portion of a predeterminedsize from the original image data 12 to be compressed that is stored instorage means and stores the portion in the buffer memory 16. In STEPS3, the data compression control section 20 selects and sets thecompression parameter value of the data compression circuit 18. In STEPS4, the data compression control section 20 reads out the partial datastored in the buffer memory 16. STEP S4 may be carried out before STEPS3 or STEPS S3 and S4 may be carried out simultaneously. In STEP S5, thedata compression circuit 18 compresses the partial data read out in STEPS4 in predetermined format by use of the compression parameter value setin STEP S3 to prepare compressed partial data. In STEP S6, the preparedcompressed partial data is output from the interleave compressionsection 6.

In STEP S7, it is determined whether STEPS S3 to S6 have been repeatedfor a predetermined number of times. If not, the data compressioncontrol section 20 returns to STEP S3. The data compression controlsection 20 sets the value of the compression parameter of the datacompression circuit 18 at a value different from the last value eachtime it repeats STEP S3. As a result, a number of compressed partialdata compressed with different compression parameter values are preparedfrom partial data, and these compressed partial data are output from theinterleave compression section 6 sequentially. After repeating STEPS S3to S6 for the number of compression parameter values used, the datacompression control section 20 proceeds to STEP S8. In STEP S8, it isdetermined whether all required portions of the image data 12 to becompressed have been extracted. If not, the data compression controlsection 20 returns to STEP S2, and the data acquisition control section14 discards the partial data stored in the buffer memory 16, extractspartial data different from the previously extracted partial data fromthe image data 12 to be compressed and stores the newly extractedpartial data in the buffer memory 16. STEPS S3 to S6 are also repeatedfor the partial data which has been newly stored in the buffer memory 16for the number of compression parameter values used, and a number ofcompressed partial data prepared from this partial data are output fromthe interleave compression section 6 sequentially. As a result ofrepetitions in STEPS S7 and S8, an output from the interleavecompression section 6 is an output resulting from interleaving datacompressed with a compression parameter value by data compressed withanother compression parameter value. These will be described by use ofFIGS. 3 and 4 hereinafter.

FIG. 3 is a schematic diagram illustrating compression by the interleavecompression section 6. In FIG. 3, P₁, P₂ and P₃ represent partial datawhich constitute different portions of the original image data 12. WhenP₁ is stored in the buffer memory 16 in STEP S2 shown in FIG. 2, thedata compression control section 20 sets the value of the compressionparameter of the data compression circuit 18 at Q_(a) (STEP S3), readsout the partial data P₁ from the buffer memory 16 (STEP S4), andcompresses the retrieved P₁ with the compression parameter value Q_(a)to prepare compressed partial data P_(1a) (STEP S5). The preparedcompressed partial data P_(1a) is output from the interleave compressionsection 6 (STEP S6). If returning to STEP S3 by STEP S7, the datacompression control section 20 sets the value of the compressionparameter of the data compression circuit 18 at Q_(b) which is differentfrom Q₁ and reads out the partial data P₁ stored in the buffer memory 16(STEPS S3 and S5). Then, the data compression circuit 18 compresses thepartial data P₁ with the parameter value Q_(a) to prepare compressedpartial data P_(1b) (STEP S5). Likewise, compressed partial data P_(1c)is prepared by compressing the partial data P₁ with a parameter valueQ_(c), and compressed partial data P_(1d) is prepared by compressing thepartial data P₁ with a parameter value Q_(d).

After repeating STEPS S3 to S6 for the number of compression parametervalues used, the data compression control section 20 returns to STEP S2and discards the partial data P₁ stored in the buffer memory 16,extracts new partial data P₂ from the image data 12 and stores thepartial data P₂ in the buffer memory 16. As in the case of the partialdata P₁, P₂ is compressed with the different parameter values Q_(a) toQ_(d) to prepare compressed partial data P_(2a) to P_(2d) which are thenoutput sequentially (STEPS S3 to S6). Upon completion of processing ofthe partial data P₂, the data compression control section 20 returns toSTEP S2 again (STEP S8), and the next partial data P₃ is extracted,compressed with the different parameter values Q_(a) to Q_(d) to preparecompressed partial data P_(3a) to P_(3d) which are then outputsequentially (STEPS S3 to S7). Eventually, a series of data output fromthe interleave compression section 6 become those shown FIG. 4, forexample.

FIG. 4 is a schematic diagram illustrating data output from theinterleave compression section 6. As is clear from FIG. 4, unlike theprior art, the outputs from the interleave compression section 6 do nottake a form that data compressed with the same compression parametervalue are continued sequentially. Instead, these outputs take a formthat compressed data obtained by compressing the same partial data withdifferent compression parameter values are continued to a certain pointand compressed data obtained by compressing another partial data withdifferent compression parameter values are continued after the certainpoint. That is, they are outputs resulting from interleaving datacompressed with a compression parameter value by data compressed withanother compression parameter value different from the above compressionparameter value. This is a characteristic of the present invention.Thus, a compression method which repeats the following two steps, i.e. astep of extracting a portion of a predetermined size from image data tobe compressed and a step of preparing a predetermined number ofcompressed partial data compressed with different compression parametervalues from the partial data by repeating preparation of compressedpartial data by compressing the partial data in predetermined format forthe predetermined number of times with the compression parameter valueused in the predetermined format changed for each compression, on theentire image data to be compressed, as described in STEPS S2 to S5, willbe referred to as “interleave compression” hereinafter.

Upon completion of processing of the entire image data to be compressedin STEP S8, compression processing is ended (STEP S9). STEPS S2 to S7 donot need to be carried out on all portions of the image data to becompressed, in other words, on portions which may be discarded withoutcompression. For example, when the image data 12 to be compressed issubjected to a thinning process when JPEG is used as a data compressionformat, the data acquiring control section 14 can be so constituted asnot to store portions of the image data 12 which are to be discarded inthe buffer memory 16.

Hereinafter, the operation of the image data compression device 2according to the present invention will be further described withreference to FIG. 2. The compressed partial data output from theinterleave compression section 6 in STEP S6 are allocated to appropriatestorage locations in the RAM 9 by the memory controller 8 in STEP S15and actually stored in the RAM 9 in STEP S11. Thus, after compressionprocessing is ended in STEP S9, all compressed partial data prepared bythe interleave compression section 6 are stored in the RAM 9 such thatcompressed partial data compressed with the same compression parametervalue are collectively stored in the same area in the RAM 9. In STEPS12, the CPU 22 checks the compressed partial data stored in the RAM 9and calculates the total of the data sizes of all compressed partialdata compressed with the same compression parameter value for eachcompression parameter value in accordance with the program stored in theROM 21. Then, in STEP S13, the CPU 22 selects compressed partial datacompressed with a compression parameter value for which the total of thedata sizes of the compressed partial data is not larger than a giventhreshold and which is the closest value to the threshold.

Next, STEPS S12 and S13 will be described by use of FIG. 5. FIG. 5 is aschematic diagram illustrating compressed partial data stored in the RAM9. As shown in FIG. 5, in the RAM 9, compressed partial data using thesame compression parameter value are collectively stored in the samearea. In FIG. 5, C_(a) represents a group of compressed partial datacompressed with a compression parameter value Q_(a), and C_(b)represents a group of compressed partial data compressed with acompression parameter value Q_(b). Similarly, C_(c) represents a groupof compressed partial data compressed with a compression parameter valueQ_(c), and C_(d) represents a group of compressed partial datacompressed with a compression parameter value Q_(d). The horizontaldirection in FIG. 5 indicates a data size, and in this example, the datasize of C_(a) is the largest and the data size of C_(d) is the smallest.The CPU 22 calculates the total data sizes of C_(a), C_(b), C_(c) andC_(d) in accordance with the program stored in the ROM 21 (STEP S12). Itcan be seen that in the example illustrated in FIG. 5, C₂ has a datasize which is not larger than a given threshold and which is the closestto the threshold. Thus, the CPU 22 selects C₂ in accordance with theprogram stored in the ROM 21. When the total of the data sizes of thecompressed partial data is larger than the threshold for all of thecompression parameter values used, i.e. when the total of the data sizesof C_(a), C_(b), C_(c) or C_(d) is larger than the threshold in theexample of FIG. 5, a group of compressed partial data whose total datasize is the smallest is selected (in this example, C_(d) is selected.)

Returning to FIG. 2, in STEP S14, the CPU 22 prepares a compressed imagedata file which is a final output from the selected compressed partialdata in accordance with the program stored in the ROM 21. The compressedimage data file includes compression information of the entire originalimage data 12. Further, when a JPEG format is used as the predeterminedformat, the compressed image data file is so constituted as to be a fileformat defined in JPEG standard. Thereby, preparation of the compressedimage data file is completed (STEP S15). The prepared compressed imagedata file is output to an external storage unit.

Although only three partial image data P₁, P₂ and P₃ are described asportions of image data in the above description, it should be understoodthat the image data is actually constituted by a considerably largenumber of portions. For example, image data of UXGA, i.e. 1600pixels×1200 pixels, is considered as image data to be compressed, and aportion having a size of 8 pixels×8 pixels is considered as the partialdata. In this case, since image data is constituted by three planes ofRGB or YUV, the image data is constituted by (1600/8)×(1200/8)×3=90,000partial data. Even when ¾ data of the U and V components are discardedwhen compression in JPEG format is used, 45,000 partial data from theimage data must be processed to obtain a final compressed image datafile.

Another embodiment may be constituted as follows to calculate the totalof the data sizes of all compressed partial data compressed with thesame compression parameter value. First, the interleave compressionsection 6 is provided with a function of determining the data size ofprepared compressed partial data and is so constituted as to output thecompressed partial data with the determined data size value attachedthereto. Then, the memory controller 8 is provided with a function ofadding a data size value attached to compressed partial data each timethe compressed partial data is input. As a matter of course, theaddition is carried out for each compression parameter value used forcompression of the compressed partial data. The added values are storedin appropriate locations in the RAM 9. With such a constitution, afterthe memory controller 8 processes all compressed partial data preparedfrom the image data 12, the CPU 22 can determine a compression parametervalue which implements an optimum data size simply by reading an addedvalue stored in the location in the RAM 9, whereby the throughput of theCPU 22 can be decreased.

In still another embodiment, all functions of the data file preparingsection 10 can also be implemented by software. That is, when compressedpartial data output from the interleave compression section 6 are storedin the RAM 9, the compressed partial data may be stored in the RAM 9 inthe order they are input into the data file preparing section 10 withoutclassifying them by compression parameter values used for compression.In this case, the CPU 22 must cooperate with the program stored in theROM 21 to group the compressed partial data in the RAM 9 by thecompression parameter values used for compression and calculate thetotals of the data sizes of the data.

Embodiment 1

Embodiment 1 illustrates an example of practicing the present inventionas an image data compression device which compresses image data toprepare a compressed image data file in JPEG format. FIG. 6 is aschematic diagram showing the hardware configuration of the image datacompression device. An image data compression unit 26 comprises apartial data acquiring section 28, an interleave compression section 30,a RAM 9 and a data file preparing section 60, as in the case of theabove-described image data compression device 2.

The partial data acquiring section 28 in the present embodimentcomprises a buffer memory 31 and a data acquiring section controlsection 32, as in the case of the partial data acquiring section 4 inthe image data compression device 2 of FIG. 1. These functions are thesame as those of the partial data acquiring section 4 in the image datacompression device 2 of FIG. 1 except for two additional functions. Oneof the additional functions is a function that the data acquiringsection control section 32 carries out a thinning process defined inJPEG format while it is taking in partial data from image data 34 to becompressed. That is, the data acquiring section control section 32 is soconstituted as not to take portions of the image data 34 to becompressed which are to be discarded without compression in JPEG formatinto the buffer memory 31. The other additional function is to carry outDCT (discrete cosine transform) before storing the taken-in partial datain the buffer memory 31. For this purpose, the partial data acquiringsection 28 comprises a DCT circuit 36.

The interleave compression section 30 in the present embodimentcomprises a data compression circuit 38 and a data compression controlsection 40, as in the case of the interleave compression section 6 inthe image data compression device 2 of FIG. 1. These functions are thesame as those of the interleave compression section 6 in the image datacompression device 2 of FIG. 1 except that the interleave compressionsection 30 in the present embodiment is optimized to use a JPEG formatas a compression format. The data compression circuit 38 comprises a Qtable storing section 42, a Q factor storing section 44, a multiplier46, a divider 48, a zigzag converting section 50, an entropy codingsection 51 and an RST inserting section 52. Q factors and a Q table arecompression parameters defined in JPEG format, and the size of dataafter compression is changed by changing the values of these parameters.In the present embodiment, a number of Q factor values are stored in theQ factor storing section 44, and the values of Q factors to be used forquantization can be switched from one to another under the control ofthe data compression control section 40. As a matter of course, anembodiment is also conceivable in which a number of Q tables are storedin the Q table storing section 42 and the Q tables can be switched fromone to another. While the Q factors are coefficients, the Q table is amatrix. Therefore, the terms “compression parameter values” in the abovedescription include a possibility of being a matrix. Unlike an RSTinserting section in a conventional JPEG compression device, the RSTinserting section 52 gives the same RST marker to all of partial datacompressed with the same Q factor and gives different RST markers topartial data compressed with different Q factors. That is, the RSTmarker is inserted as an identification marker for identifying acompression parameter value used for compression, i.e. the value of a Qfactor. For example, RST1 is given to all of partial data compressedwith a Q factor of 1, and RST2 is given to all of partial datacompressed with a Q factor of 2.

The data file preparing section 60 in the present embodiment comprises amemory controller 53, a ROM 54, a RAM 55 and a CPU 56, as in the case ofthe data file preparing section 10 in the image data compression device2 of FIG. 1. These functions are the same as those of the data filepreparing section 10 in the image data compression device 2 of FIG. 1except that the data file preparing section 60 in the present embodimentprepares a compressed image data file which is a final output of theimage data compression unit 26 in standard JPEG file format. The RAM 55stores compressed partial data which is output from the interleavecompression section 30. The memory controller 53 allocates the addressesof storage locations in the RAM 55 to the compressed partial data outputfrom the interleave compression section 30 according to Q factor valuesused for compression so that partial data compressed with the same Qfactor value are collectively stored in the same area in the RAM 9. TheROM 54 stores a program which causes the CPU 56 to operate as aninformation processing unit. The CPU 56 checks the data stored in theRAM 55, calculates the total of the data sizes of all partial datacompressed with the same Q factor value for each Q factor value, andselects partial data compressed with a Q factor value for which theabove total is not larger than a given threshold and which is theclosest to the threshold, in accordance with the program stored in theROM 54. Then, in accordance with the program stored in the ROM 54, theCPU 56 prepares a compressed image data file which is a final output ofthe image data compression unit 26 in standard JEPG file format from theselected compressed partial data. At this point, the CPU 56 and theprogram stored in the ROM 54 must remove the RST markers given asmarkers for identifying the Q factor value used for compression from theselected compressed partial data and gives new RST markers in accordancewith JPEG standard. The compressed image data file prepared by the CPU56 in accordance with the program stored in the ROM 54 is equivalent toa compressed image data file prepared by a conventional JPEG compressiondevice by compressing the entire image data 34 in JPEG format and can behandled by a personal computer or the like as image data.

Further, the image data compression unit 26 in the present embodiment ischaracterized in that it is separated into an image data compressionsection 58 which performs compression and the data file preparingsection 60 which prepares a compressed image data file which is a finaloutput from interleaved compressed partial data. The present inventioncan be practiced as such an embodiment, and the embodiment is convenientwhen the image data compression device according to the presentinvention is incorporated into a camera-equipped electronic device whosecamera portion and other portion are produced separately. For example,in a camera-equipped cellular phone whose camera module and telephonemodule are produced separately, an embodiment is conceivable in whichthe image data compression section 58 is incorporated into the cameramodule and the data file preparing section 60 is incorporated into thetelephone module. By implementing the cellular phone in such a form, areduction in the size of the camera module can be achieved, and the CPU56 and the RAM 55 can also be used as a CPU and a RAM which are requiredby the telephone module. The image data compression section 58 comprisesa data output section 61 which outputs compressed partial data, and thedata file preparing section 60 comprises a data input section 62 whichinputs the compressed partial data. The data output section 61 not onlyoutputs compressed partial data prepared by the interleave compressionsection 30 but also shapes the compressed partial data according to thespecification of interface between the data output section 61and thedata input section 62. The data input section 62 unshapes the compressedpartial data shaped by the data output section 61 and passes theunshaped compressed partial data to the memory controller 53.

Next, the operation of the image data compression section 58 in theimage data compression unit 26 according to the present invention willbe described by use of a flowchart of FIG. 7.

First, processing is started in STEP S21. In STEP S22, the dataacquisition control section 32 extracts a portion of a predeterminedsize from the image data 34 to be compressed that is stored in storagemeans. If the portion is to be discarded by the setting of JPEG, theportion is not extracted and the next required portion is extracted. Theextracted partial data is converted into data of frequency domain by theDCT circuit 36 (STEP S23) and stored in the buffer memory 31 (STEP S24).In STEP S25, the data compression control section 40 selects and readsout an appropriate Q factor value from the Q factor storing section 44.In STEP S26, the data compression control section 40 reads out a Q tablefrom the Q table storing section 42. In STEP S27, the Q table read outin STEP S26 is multiplied by the Q factor selected and read out in STEPS25 in the multiplier 46. In STEP S28, the data compression controlsection 40 reads out the partial data stored in the buffer memory 31. InSTEP S29, the partial data read out in STEP S28 is divided by the Qtable multiplied by the Q factor in STEP S27 in the divider 48. In STEPS28, so-called quantization in JPEG format is carried out.

In STEP S30, the quantized partial data is subjected tozigzag-conversion in the zigzag converting section 50, and in STEP S31,the zigzag-converted partial data is subjected to entropy coding in theentropy coding section 51. In STEP S32, an RST marker is given to theentropy-coded partial data in the RST inserting section 52. In STEP S32,unlike giving of RST marker in a conventional JPEG compression device,the same RST marker is given to all of partial data compressed with thesame Q factor value, and different RST markers are given to partial datacompressed with different Q factor values. That is, in the presentembodiment, the RST marker is used as an identification marker foridentifying a Q factor value used for compression. As a matter ofcourse, a marker other than the RST marker may be defined and used. InSTEP S32, compressed partial data is completed. In STEP S33, the dataoutput section shapes the compressed partial data according to thespecification of interface between the data output section 61 and thedata input section 62 and outputs the shaped compressed partial data tothe data file preparing section 60.

In STEP S34, it is determined whether the data compression controlsection 40 has repeated STEPS S25 to S33 for a predetermined number oftimes. If not, the data compression control section 40 returns to STEPS25. The data compression control section 40 selects a Q factor valuedifferent from the previously selected Q factor values from the Q factorstoring section each time STEP S25 is repeated. As a result, each timeSTEPS S25 to S33 are repeated, the interleave compression section 30prepares a number of compressed partial data compressed with different Qfactor values from the same partial data, and these compressed partialdata are output from the data output section 61 sequentially. AfterSTEPS S25 to S33 are repeated for the number of Q factors used, it isdetermined in STEP S35 whether all required portions of the image data34 to be compressed have been extracted. If not, the image datacompression section 58 returns to STEP S22, and the data acquisitioncontrol section 32 discards the partial data stored in the buffer memory31, extracts partial data different from the previously extractedpartial data from the image data 34 to be compressed and stores thenewly extracted partial data in the buffer memory 31. STEPS S25 to S33are also repeated for the partial data which has been newly stored inthe buffer memory 31 for the number of Q factor values used, and anumber of compressed partial data compressed with different Q factorvalues are prepared from this partial data. As a result of repetitionsin STEPS S34 and S35, data output from the data output section 61 is anoutput resulting from interleaving data compressed with a Q factor valueby data compressed with another Q factor value. The contents of the dataare similar to those illustrated in FIG. 4. Upon completion ofprocessing of the entire image data 34 to be compressed, compressionprocessing is ended (STEP S36).

Next, the operation of the data file preparing section 60 in the imagedata compression device 26 in the present embodiment will be describedby use of a flowchart of FIG. 8. In STEP S41, processing is started. InSTEP S42, compressed partial data output from the data output section 61are input into the data input section 62. These compressed partial datawhich have been shaped according to the above interface specificationare unshaped in the data input section 62. In STEP S43, the memorycontroller 53 specifies the addresses of locations at which thecompressed partial data are stored in the RAM 55. At that time, thememory controller 53 allocates the addresses of the storage locations tothe compressed partial data so that partial data compressed with thesame Q factor value are collectively stored in the same area in the RAM55. In STEP S44, the compressed partial data are stored in the RAM 55sequentially. Upon completion of storage of all compressed partial datasent from the image data compression section 58, the memory controller53 notifies the CPU 56 of completion of storage of the compressedpartial data.

In STEP S45, the CPU 56 checks the compressed partial data stored in theRAM 55 and calculates the total of the data sizes of all compressedpartial data compressed with the same Q factor value for all Q factorvalues used for compression, in accordance with the program stored inthe ROM 54. Then, in STEP S46, the CPU 56 selects compressed partialdata compressed with a Q factor value for which the total of the datasizes of the compressed partial data is not larger than a giventhreshold and which is the closest value to the threshold, in accordancewith the program stored in the ROM 54. If the total of the data sizes ofthe compressed partial data is larger than the threshold for all of theQ factor values used, the CPU 56 selects compressed partial datacompressed with a Q factor value for which the total is the smallest. InSTEP S47, in accordance with the program stored in the ROM 54, the CPU56 removes the RST markers given as markers for identifying the Q factorvalue used for compression from the selected compressed partial data andgives new RST markers in accordance with JPEG standard to prepare acompressed image data file which is a final output in JPEG format.Thereby, the operation of the data file preparing section 60 iscompleted (STEP S48). The prepared compressed image data file is outputto and stored in an appropriate external storage unit 63.

Embodiment 2

Embodiment 2 illustrates an example of a camera-equipped cellular phoneaccording to the present invention.

FIG. 9 is an external view of a camera-equipped cellular phone to whichthe present invention is applied. A camera-equipped cellular phone 64has, on its front side, alphanumeric keys 66 for inputting a telephonenumber or mail text, a function key 68 for operating various functionsprovided in the camera-equipped cellular phone, an on-hook key 70 forending a telephone call, an off-hook key 72 for answering an incomingcall or making a phone call and a display 74, and has a camera module 76and a battery box cover 77 on its back side. The camera module 76 has alens 78 and a flash lamp 80. Further, the cellular phone 64 also has anantenna 82 at its top and a case 84 which holds the above componentstogether. The camera-equipped cellular phone 64 can have various otherfunctions such as a telephone book, a calculator, a date book and games,in addition to a telephone function and a camera function. To operatethese functions, the alphanumeric keys 66, function key 68, on-hook key70 and off-hook key 72 each serve multiple functions.

FIG. 10 is a schematic diagram illustrating the hardware configurationof the camera-equipped cellular phone 64 according to the presentinvention. The camera-equipped cellular phone 64 comprises the cameramodule 76 which takes an image and prepares image data and a host module86 which stores the image data and has a telephone function and a PDAfunction. The camera module 76 comprises the lens 78, an image sensor 88which converts light having entered through the lens 78 into anelectrical signal, an A/D converter 90 which digitizes the signal outputfrom the image sensor 88, an image data preparing section 92 whichprepares image data from the digitized signal output from the imagesensor 88 by color interpolation, and a memory 94 which stores the imagedata prepared by the image data preparing section 92 temporarily. Asignal output from the image sensor 88 becomes image data which can bedisplayed by use of a personal computer or printed by use of a printerfor the first time after processed by the image data preparing section92. The image data preparing section 92 can be so constituted as toprepare image data not by one frame at a time but by a predeterminednumber of lines, e.g. 16 lines, at a time. Prepared portions of imagedata are stored in the memory 94 sequentially.

The camera module 76 further comprises an image data compression section96. The image data compression section 96 is the same as the image datacompression section 58 of the compressed image data file preparingdevice according to the present invention which has been described inEmbodiment 1 and performs interleave compression using a JPEG formatwhich has been described in FIG. 7. However, the image data compressiondevice 96 is different from the image data compression section 58 inEmbodiment 1 in that the image data compression device 96 operates underthe control of a camera control section 98 to be described later as awhole. As in the case of the image data compression section 58, theimage data compression section 96 comprises a partial data acquiringsection 100, an interleave compression section 102 and a data outputsection 104. These are the same as the partial data acquiring section28, interleave compression section 30 and data output section 61 of thecompressed image data file preparing device 26 which has been describedin Embodiment 1, respectively.

The camera module 76 further comprises a camera control section 98 whichcontrols the functions of the camera module 76. The camera controlsection 98 comprises a CPU and software which operates the CPU andreceives a command from the host module 86 and thereby controls theimage sensor 88, A/D converter 90, image data preparing section 92 andimage data compression section 96. Interleave-compressed image data issent to the host module 86 through a camera-side data I/F 106, andcontrol information of the camera module 76 and the host module 86 isexchanged through a camera-side control I/F 108. In an optimumembodiment, the image data preparing section 92 and the image datacompression section 96 are preferably constituted as hardware circuits.Further, these hardware circuits and the camera control section 98 arepreferably integrated and constituted as one LSI chip as a photographingcontrol unit 110.

The host module 86 comprises an application processing section 112, abaseband processing section 114 which controls a telephone function, theantenna 82, a main storage unit 116 such as a DRAM, an external storageunit 118 which is a storage unit suited for long-term data storage suchas an SD card or MMC card, a keypad 120 which comprises the keys 66, 68,70 and 72, and the display 74. The application processing section 112comprises a processor 122, a ROM 124 which stores a program foroperating the processor 122, a memory controller 125, a host-side dataI/F 126 which receives data sent from the camera module 76, a host-sidecontrol I/F 128 which is a path for exchanging control informationbetween the host module 86 and the camera module 76, and a bus 130.Further, the main storage unit 116 is connected to the processor 122 andthe memory controller 125 through a bus 129, and the external storageunit 118, the key pad 120 and the display 74 are connected to theprocessor 122 through the bus 130. The program stored in the ROM 124cooperates with the processor 122 to implement the same function as thatof the data file preparing section 60 of the image data compressiondevice 26 which has been described in Embodiment 1 and implement variousother functions such as a telephone book, a calculator, a date book andgames.

The camera module 76 is directly controlled by the camera controlsection 98. The camera control section 98 receives a command from theapplication processing section 112 to implement control of the cameramodule 76. For example, when a shutter button in the keypad 120 ispressed, the application professing section 112 detects the press andsends a command to take an image to the camera control section 98through the host-side control I/F 128 and the camera-side control I/F108. Upon receipt of the command, the camera control section 98interprets the command and directly controls the image sensor 88, theA/D converter 90, the image data preparing section 92 and the image datacompression section 96 to implement photographing and preparation andcompression of image data.

Next, the operation of the camera module 76 when photographing iscarried out by use of the camera-equipped cellular phone 64 in thepresent embodiment will be described by use of a flowchart of FIG. 11.

First, photographing is started in STEP S51. In STEP S52, the imagesensor 88 is exposed. In STEP S53, an electrical signal output from theimage sensor 88 is converted into a digital signal. In STEP S54, theimage data preparing section 92 prepares image data which can be handledby a personal computer and a printer from the digitized signal outputfrom the image sensor 88. The prepared image data is stored in thememory 94 (STEP S55). In STEP S56, the partial data acquiring section100 extracts partial data of a predetermined size from the memory 94,subjects the partial data to DCT and stores the partial data inside.This process is the same as those described in STEPS S22 to S24 in FIG.7. In STEP S57, the interleave compression section 102 prepares a numberof compressed partial data compressed with different Q factor valuesfrom the partial data stored in the partial data acquiring section 100.This process is the same as those described in STEPS S25 to S32 in FIG.7. In STEP S58, the compressed partial data prepared by the interleavecompression section 102 are shaped according to the specification of thedata I/F and output from the data output section 104 sequentially. InSTEP S59, it is determined whether all required portions of the imagedata 34 to be compressed have been compressed. If not, STEPS S56 to S58are carried out again. Otherwise, processing is ended (STEP S60).

In STEP S54, the image data preparing section 92 prepares image data notby one frame at a time but by a predetermined number of lines, e.g. 16lines, at a time. Although prepared portions of the image data arestored in the memory 94, the photographing control unit 110 can be soconstituted as to interleave-compress all portions of the image datawhich are stored in the memory 94 before the next prepared portion ofthe image data is stored in the memory 94. By constituting thephotographing control unit 110 as described above, it is sufficient thatthe memory 94 has a capacity of storing, for example, 16 lines, leadingto reductions in the space of the camera module and production costs.

Next, the operation of the host module 86 when a picture is taken by thecamera-equipped cellular phone 64 in the present embodiment will bedescribed by use of a flowchart of FIG. 12. Hereinafter, only anoperation thereof associated with processing of compressed partial dataoutput from the camera module 76 will be described.

In STEP S61, processing is initiated. In STEP S62, a series ofcompressed partial data are input into the camera module 76 through thecamera-side data I/F 106 and the host-side data I/F 126. Thesecompressed partial data which have been shaped according to thespecification of the above interface are unshaped in the data inputsection 62. In STEP S63, the memory controller 125 specifies theaddresses of storage locations of the compressed partial data in themain storage unit 116. At that time, the memory controller 125 allocatesthe addresses of storage locations to the compressed partial data sothat compressed partial data compressed with the same Q factor value arecollectively stored in the same area in the main storage unit 116. InSTEP S64, the compressed partial data are stored in the main storageunit 116 sequentially. Upon completion of storage of all compressedpartial data sent from the image data compression section 58, the memorycontroller 125 notifies the processor 122 of completion of storage.

In STEP S65, the processor 122 checks the compressed partial data storedin the main storage unit 116 and calculates the total of the data sizesof all compressed partial data compressed with the same Q factor valuefor all Q factor values used for compression, in accordance with theprogram stored in the ROM 124. Then, in STEP S66, the processor 122selects compressed partial data compressed with a Q factor value forwhich the total of the data sizes of the compressed partial data is notlarger than a given threshold and which is the closest value to thethreshold, in accordance with the program stored in the ROM 124. If thetotal of the data sizes of the compressed partial data is larger thanthe threshold for all of the Q factor values used, the processor 122selects compressed partial data compressed with a Q factor value forwhich the total is the smallest. In STEP S67, in accordance with theprogram stored in the ROM 124, the processor 122 removes the RST markersgiven as markers for identifying the Q factor value used for compressionfrom the selected compressed partial data and gives new RST markers inaccordance with JPEG standard to prepare a compressed image data filewhich is a final output in JPEG format. In STEP S69, the preparedcompressed image data file in JPEG format is stored in the externalstorage unit 118, thereby ending the processing (STEP S69).

The camera-equipped cellular phone 64 preferably previews photographedand prepared image data on the display 74. Several constitutions can beconceived to impart such a function, and the following constitution canbe adopted, for example. First, all digitized signals output from theimage sensor 88 are stored in appropriate storage means once. The imagedata preparing section 92 reads out the stored output signals from thestorage means and resizes the signals to prepare image data for preview.Thereafter, the image data preparing section 92 reads out the outputsignals of the image sensor 88 from the storage means again to prepareimage data to be stored and then subjects the prepared image data tointerleave compression. Since the image data for preview has lowresolution (e.g. 240 pixels×120 pixels), the image data for preview doesnot need to be compressed by the image data compression section 96. Theimage data for preview is sent to the host module 86 before allcompressed partial data.

In another constitutional example, it is conceivable to impart afunction of preparing image data for preview to the image datacompression section 96. In this constitutional example, the image datacompression section 96 is so constituted as to prepare partial data forpreview image by simply reducing the resolution of partial data storedin the partial data acquiring section 100, output the partial data forpreview image from the data output section and then compress the partialdata. That is, in this constitution, the partial data for preview imageand a number of compressed partial data are output which are preparedfrom the same partial data are output from the camera module 76sequentially. The partial data for preview image does not need to beprepared for all partial data stored in the partial data acquiringsection 100, and it is sufficient that the partial data for previewimage is prepared for some of the partial data. In this constitutionalexample, the processor 122 must have a function of preparing previewimage data to be displayed on the display 74 from partial data forpreview image which are stored in different areas in the main storageunit 116 in accordance with the program stored in the ROM 124.

The embodiments of the present invention have been described above. Itis needless to say that the embodiments described above are merelyembodiments for practicing the present invention and various otherembodiments are also possible. For example, the compression format usedin the present invention is not limited to JPEG. Further, even when JPEGis used, an embodiment which uses a Huffman table as a compressionparameter which is changed in interleave compression and an embodimentwhich uses a marker other than RST as a marker indicating a compressionparameter value used for compression are also possible. In JPEGstandard, markers which are applicable as the above marker are defined,in addition to RST. Further, the embodiments of the present inventionare not limited to hardware. The present invention can also be practicedas computer software incorporating the method for preparing a compressedimage data file according to the present invention. In addition,although the present invention can be suitably applied to electronicdevices including camera-equipped cellular phones, PDAs and portablecomputers, the present invention is not limited to those electronicdevices and can also be applied to a digital camera 202 which is adevice used specifically for photography and other devices. In any case,various embodiments can be practiced without departing from the scope ofthe present invention.

1. A method for preparing a compressed image data file by compressingimage data, the method comprising: extracting a portion of apredetermined size from the image data, and preparing a predeterminednumber of compressed partial data compressed with different compressionparameter values from the partial data by repeating preparation ofcompressed partial data by compressing the partial data in predeterminedformat for the predetermined number of times with the compressionparameter value used in the predetermined format changed for eachcompression, on the entire image data, and the method further comprisingcalculating the total of the data sizes of all of the compressed partialdata compressed with the same compression parameter value for each ofthe compression parameter values and preparing the compressed image datafile from compressed partial data compressed with a compressionparameter value for which the total is not larger than a given thresholdand which is the closest value to the threshold.
 2. The method accordingto claim 1, wherein when the total is larger than the threshold for allof the compression parameter values, the compressed image data file isprepared from compressed partial data compressed with a compressionparameter value for which the total is the smallest.
 3. The methodaccording to claim 1, wherein the predetermined format is a JPEG format.4. The method according to claim 3, wherein the compression parametersare Q factors or Q tables defined in JPEG format.
 5. An image datacompression device which compresses image data to prepare a compressedimage data file, the device comprising: partial data acquiring means,interleave compression means, and data file preparing means, wherein thepartial data acquiring means acquires a portion of a predetermined sizefrom the image data, the interleave compression means prepares a numberof compressed partial data compressed with different compressionparameter values from the partial data by repeating preparation ofcompressed partial data by compressing the partial data in predeterminedformat for a predetermined number of times with the compressionparameter value used in the predetermined format changed for eachcompression and outputs the compressed partial data sequentially, andthe data file preparing means calculates the total of the data sizes ofall of the compressed partial data compressed with the same compressionparameter value for each of the compression parameter values andprepares the compressed image data file from compressed partial datacompressed with a compression parameter value for which the total is notlarger than a given threshold and which is the closest value to thethreshold.
 6. The device according to claim 5, wherein when the total islarger than the threshold for all of the compression parameter values,the compressed image data file is prepared from compressed partial datacompressed with a compression parameter value for which the total is thesmallest.
 7. The device according to claim 5, wherein the predeterminedformat is a JPEG format.
 8. The device according to claim 7, wherein thecompression parameters are Q factors or Q tables defined in JPEG format.9. An image data compression device which compresses image data toprepare a compressed image data file, the device comprising: an imagedata compression section, and a data file preparing section, wherein thedata compression section comprises: a partial data acquiring section, aninterleave compression section, and a data output section, the partialdata acquiring section takes in a portion of a predetermined size fromthe image data and stores the partial data temporarily, the interleavecompression section compresses the partial data stored in the partialdata acquiring section in predetermined format to prepare compressedpartial data, the data output section outputs the compressed partialdata, the interleave compression section comprises a number ofcompression parameter values used in the predetermined format andprepares a number of compressed partial data compressed with differentcompression parameter values from the partial data, the data outputsection outputs the compressed partial data sequentially, the data filepreparing section comprises: a data input section, a data storingsection, a data size calculating section, a data size determiningsection, and a data shaping section, the data input section inputs theoutput compressed partial data, the data storing section stores thecompressed partial data input from the data input section, the data sizecalculating section calculates the total of the data sizes of all ofcompressed partial data prepared from the same image data and compressedwith the same compression parameter value out of the compressed partialdata input from the data input section for each of the differentcompression parameter values, the data size determining sectiondetermines that a compression parameter value for which the total is notlarger than a given threshold and which is the closest value to thethreshold is an optimum compression parameter value, and the datashaping section prepares the compressed image data file from compressedpartial data compressed with the optimum compression parameter value.10. The device according to claim 7, wherein when the total is largerthan the threshold for all of the compression parameter values, the datasize determining section determines that a compression parameter valuefor which the total is the smallest is an optimum compression parametervalue.
 11. The device according to claim 9, wherein the interleavecompression section gives markers indicating the compression parametervalues used for compression to the compressed partial data.
 12. Thedevice according to claim 9, wherein the predetermined format is a JPEGformat.
 13. The device according to claim 12, wherein the compressionparameters are Q factors or Q tables defined in JPEG format.
 14. Thedevice according to claim 12, wherein an RST marker defined in JPEGformat is used as the marker.
 15. The device according to claim 14,wherein the data shaping section removes the RST markers from thecompressed partial data and gives new RST markers to the compressedpartial data in accordance with JPEG standard.
 16. A photographic devicecomprising: a camera module, and a host module, wherein the cameramodule comprises: a sensor section, an image data preparing section, acamera-module-side data storing section, a partial data acquiringsection, an interleave compression section, and a data transmittingsection, the sensor section converts incoming light into an electricalsignal, the image data preparing section prepares image data from theelectrical signal, the camera-module-side data storing section stores apart or all of the image data temporarily, the partial data acquiringsection takes in a portion of a predetermined size from the image datastored in the camera-module-side data storing section and stores thepartial data temporarily, the interleave compression section compressesthe partial data stored in the partial data acquiring section inpredetermined format to prepare compressed partial data, the datatransmitting section transmits the compressed partial data to the hostmodule, the interleave compression section comprises a number ofcompression parameter values used in the predetermined format andprepares a number of compressed partial data compressed with differentcompression parameter values from the partial data, the datatransmitting section transmits the compressed partial data sequentially,the host module comprises: a data receiving section, a host-side datastoring section, a data size calculating section, a data sizedetermining section, a data shaping section, and a file storage unit,the data receiving section receives the data transmitted from the cameramodule, the host-side data storing section stores the compressed partialdata received by the data receiving section, the data size calculatingsection calculates the total of the data sizes of all of compressedpartial data prepared from the same image data and compressed with thesame compression parameter value out of the compressed partial datareceived by the data receiving section for each of the differentcompression parameter values, the data size determining sectiondetermines that a compression parameter value for which the total is notlarger than a given threshold and which is the closest value to thethreshold is an optimum compression parameter value, the data shapingsection prepares a compressed image data file including information ofthe entirely compressed image data from compressed partial datacompressed with the optimum compression parameter value, and the filestorage unit stores the compressed image data file.
 17. The deviceaccording to claim 16, wherein when the total is larger than thethreshold for all of the compression parameter values, the data sizedetermining section determines that a compression parameter value forwhich the total is the smallest is an optimum compression parametervalue.
 18. The device according to claim 16, wherein the host module hasa telephone function.
 19. The device according to claim 18, wherein thehost module has a telephone function using CDMA.
 20. The deviceaccording to claim 16, wherein the image data preparing section in thecamera module prepares preview image data for preview from theelectrical signal before preparing the image data, and the datatransmitting section in the camera module transmits the preview imagedata to the host module before transmitting the compressed partial data,and the host module comprises a display device and receives the previewimage data and displays it on the display device.
 21. The deviceaccording to claim 16, wherein the data compression section in thecamera module prepares partial data for preview image whose resolutionis lower than the partial data from the partial data, and the datatransmitting section in the camera module transmits the partial data forpreview image prepared from the partial data and the compressed partialdata sequentially, and the host module comprises a display device andstores the partial data for preview image in the host-side data storingsection, prepares image data for preview of the image data from thepartial data for preview image which is stored in the host-side datastoring section by the data shaping section and displays the image datafor preview on the display device.
 22. The device according to claim 16,wherein the interleave compression section gives markers indicating thecompression parameter values used for compression to the compressedpartial data.
 23. The device according to claim 16, wherein thepredetermined format is a JPEG format.
 24. The device according to claim23, wherein the compression parameters are Q factors or Q tables definedin JPEG format.
 25. The device according to claim 23, wherein an RSTmarker defined in JPEG format is used as the marker.
 26. The deviceaccording to claim 25, wherein the data shaping section removes the RSTmarkers from the compressed partial data and gives new RST markers tothe compressed partial data in accordance with JPEG standard.